package com.travel.haoma.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import com.travel.haoma.R;

import cn.haoma.base.common.BaseActivity;
import cn.haoma.base.common.Id;
import cn.haoma.base.common.LayoutId;

@LayoutId(R.layout.act_main)
public class ActMain extends BaseActivity {
    @Id(R.id.tab_content)
    private FrameLayout tabContent;
    @Id(R.id.bt_tab1)
    private View btTab1;
    @Id(R.id.bt_tab2)
    private View btTab2;
    @Id(R.id.bt_tab3)
    private View btTab3;
    @Id(R.id.bt_tab4)
    private View btTab4;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTabSelected(btTab1);
        getSupportFragmentManager().beginTransaction().replace(R.id.tab_content,new FrgTimeImg()).commit();
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.bt_tab1:
                setTabSelected(btTab1);
                break;
            case R.id.bt_tab2:
                setTabSelected(btTab2);
                break;
            case R.id.bt_tab3:
                setTabSelected(btTab3);
                break;
            case R.id.bt_tab4:
                setTabSelected(btTab4);
                break;
        }
    }

    private void setTabSelected(View viewSelected){
        View[] views = new View[]{btTab1,btTab2,btTab3,btTab4};
        for (int i=0;i<views.length;i++){
            if(views[i].getId()==viewSelected.getId()){
                views[i].setSelected(true);
            }else views[i].setSelected(false);
        }
    }

}
